// import { faker } from "@faker-js/faker";
// fake/user.fake.ts
// import Mock from "mockjs";
import { defineFakeRoute } from "vite-plugin-fake-server/client";

export default defineFakeRoute([
  {
    url: "/login",
    method: "post",
    response: ({ body }) => {
      if (body.username === "admin") {
        return {
          success: true,
          data: {
            avatar: "https://avatars.githubusercontent.com/u/44761321",
            username: "admin",
            nickname: "小铭123",
            // 一个用户可能有多个角色
            roles: ["admin"],
            // 按钮级别权限
            permissions: ["*:*:*"],
            accessToken: "eyJhbGciOiJIUzUxMiJ9.admin",
            refreshToken: "eyJhbGciOiJIUzUxMiJ9.adminRefresh",
            expires: "2030/10/30 00:00:00",
          },
        };
      } else {
        return {
          success: true,
          data: {
            avatar: "https://avatars.githubusercontent.com/u/52823142",
            username: "common",
            nickname: "小林123",
            roles: ["common"],
            permissions: ["permission:btn:add", "permission:btn:edit"],
            accessToken: "eyJhbGciOiJIUzUxMiJ9.common",
            refreshToken: "eyJhbGciOiJIUzUxMiJ9.commonRefresh",
            expires: "2030/10/30 00:00:00",
          },
        };
      }
    },
  },
  //   {
  //     url: "/fake/get-user-info",
  //     response: () => {
  //       return {
  //         id: faker.string.uuid(),
  //         avatar: faker.image.avatar(),
  //         birthday: faker.date.birthdate(),
  //         email: faker.internet.email(),
  //         firstName: faker.person.firstName(),
  //         lastName: faker.person.lastName(),
  //         sex: faker.person.sexType(),
  //         role: "admin",
  //       };
  //     },
  //   },
]);
